4

I need to install Numpy on my Mac OS X Lion 10.7. I googled a little bit, it seems like there are a lot of stuff needs to be installed. And some says I need install Xcode before I install Numpy. But the official website of Numpy doesn't give much information about installing Numpy on Mac. I really don't want to install Xcode as it would cost a lot space.

So anyone knows how to install Numpy? What's the prerequisites?

Thanks,

gcamp
14.7k4 gold badges57 silver badges86 bronze badges
asked Sep 7, 2011 at 17:31
2
  • 2
    is the numpy that comes with osx not sufficient? Commented Sep 7, 2011 at 17:48
  • Sometimes it is not, for some software packages. Commented Feb 12, 2012 at 6:03

9 Answers 9

13

Lion comes with numpy installed. It should already be there:

$ python -c 'import numpy, numpy.version; print numpy, numpy.version.version'
<module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py'> 1.5.1
answered Sep 7, 2011 at 17:54
7

For anyone that hits this from google, here is where I figured out how to build numpy on Mac OS.

http://www.scipy.org/Installing_SciPy/Mac_OS_X

On lion, it amounts to setting some environment variables (after Xcode is installed):

export CC=gcc-4.2
export CXX=g++-4.2
export FFLAGS=-ff2c

Then pip install numpy works just fine.

answered Mar 14, 2012 at 15:44
3

I have used a few software packages that require a fresh install of NumPy, that won't work with the built in NumPy or even with the built-in Python. The easiest way to install NumPy on the mac is to download any of these packages. This will work for most OS versions.

Still the other answers are valid, though this is a more general answer.

This is the SourceForge page of the project.

answered Feb 12, 2012 at 5:46
3

If you do install Xcode you can get the latest and greatest open source libraries and packages. Consider using the excellent Mac Ports (http://www.macports.org) project. It is a package manager that will download source packages and their dependencies and build all the libraries and tools for you.

Installing Numpy becomes a one line command once Xcode and mac ports is installed:

sudo port install py27-numpy

answered Mar 6, 2012 at 17:59
2

The easiest way that I found was to visit http://sourceforge.net/projects/numpy/files/NumPy/, pick the folder of the latest version, and then download the .dmg file that matched my installed version of Python.

answered Jan 7, 2013 at 1:53
2
  • somehow this was the best option. Awesome! Commented Jun 8, 2013 at 20:55
  • this works, but notice you want a .dmg file like in El Developer's answer, but you want the OS 10.6 version not the OS 10.3 version that El Developer linked to. Commented Jun 26, 2013 at 1:39
0

Based on this post, I found that Chris Fonnesbeck keeps a highly functional installer script for OSX 10.7 at the OSX SuperPack Github site.

Because I hapened to have all the dependencies (such as gfortran) already, I did not use his full shell script. Rather I just did

git clone --depth=1 git://github.com/fonnesbeck/ScipySuperpack.git 
python -m easy_install -N -Z ScipySuperpack/*.egg 

And it worked beautifully. In particular, it worked better than the .dmg files from the official numpy and scipy distributions, and better than pip install.

answered Aug 23, 2013 at 4:35
0

You can install numpy/scipy using pip, If pip is not installed on your machine, you can install it with easy_install:

sudo easy_install pip

Then install numpy:

sudo pip install numpy
answered Nov 9, 2014 at 15:45
0

A very easy route is to install Anaconda from Continuum, or Enthought's Canopy. These are python distributions that include numpy, as well as other useful scientific computing libraries

answered Nov 9, 2014 at 19:35
-4

Generally, unless you have a good reason you might want to avoid trying to have to build numpy/scipy et al. yourself.

For Mac's there are two nice everything-included packages for numerical python. Enthough distribution (paid, http://www.enthought.com/) and Sagemath (free, http://www.sagemath.org/). I'm happily using Sagemath on 10.7 - it has numpy, scipy etc.

answered Sep 8, 2011 at 2:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.